package com.neusoft.neuiotms.dcvm.task.cmdbSyn.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.neuiotms.dcvm.task.cmdbSyn.model.CmdbSynSrcDataLast;
import com.neusoft.neuiotms.dcvm.task.cmdbSyn.respository.CmdbSynDataLastRepository;

@Service
public class CmdbSynSrcDataLastService {
    @Autowired
    private CmdbSynDataLastRepository cmdbSynSrcDataLastRepository;

    public List<CmdbSynSrcDataLast> searchDel(final String assetType) {
        return this.cmdbSynSrcDataLastRepository.searchDel(assetType);
    }

    @Transactional(rollbackFor = Exception.class)
    public void saveAll(final List<CmdbSynSrcDataLast> datas) {
        this.cmdbSynSrcDataLastRepository.saveAll(datas);
    }

    @Transactional(rollbackFor = Exception.class)
    public void deleteAllInBatch() {
        this.cmdbSynSrcDataLastRepository.deleteAllInBatch();
    }

    public List<CmdbSynSrcDataLast> searchAll() {
        return this.cmdbSynSrcDataLastRepository.findAll();
    }

    public CmdbSynSrcDataLast searchByCoding(String coding) {
        return this.cmdbSynSrcDataLastRepository.findTop1ByCoding(coding);
    }
}
